//
//  CustomCollectionViewCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/25.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "CustomCollectionViewCell.h"

@implementation CustomCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
//        _titleLab = [[UILabel alloc]init];
//        _titleLab.font = [UIFont systemFontOfSize:14];
//        _titleLab.textAlignment = NSTextAlignmentCenter;
//        _titleLab.textColor = [UIColor blackColor];
//        [self addSubview:_titleLab];
//        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.centerY.equalTo(self);
//        }];
        
    }
    
    return self;
}

//
//-(UILabel *)titleLab
//{
//    if (!_titleLab)
//    {
//        _titleLab = [[UILabel alloc]init];
//        _titleLab.font = [UIFont systemFontOfSize:14];
//        _titleLab.textAlignment = NSTextAlignmentCenter;
//        _titleLab.textColor = [UIColor blackColor];
//        [self.contentView addSubview:_titleLab];
//    }
//    return _titleLab;
//}

-(UIButton *)statusBtn
{
    if (!_statusBtn)
    {
        _statusBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _statusBtn.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        [_statusBtn setTitleColor:[UIColor blackColor] forState:0];
//        [_statusBtn setTitle:_titleLab.text forState:0];
        _statusBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_statusBtn addTarget:self action:@selector(statueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_statusBtn];
    }
    return _statusBtn;
}

-(void)setupCollectionViewWithStatus:(NSString *)_status
{
    
      NSString *IDA = [[NSUserDefaults standardUserDefaults] objectForKey:@"STATE"];
    if ([IDA isEqualToString:@"1"])
    {
        NSLog(@"---------  %@",_status);
        if ([_status isEqualToString:@"0"])
        {
            _statusBtn.backgroundColor = [UIColor whiteColor];
            [_statusBtn setTitleColor:[UIColor blackColor] forState:0];
            [_statusBtn setUserInteractionEnabled:YES];
        }
        if ([_status isEqualToString:@"2"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#ff0000"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:NO];
        }
        if ([_status isEqualToString:@"3"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#009b42"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:NO];
        }
        if ([_status isEqualToString:@"10"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#f703e5"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:NO];
        }
        if ([_status isEqualToString:@"5"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#00B8EC"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:NO];
        }

    }
    else
    {
        if (_status == 0)
        {
            _statusBtn.backgroundColor = [UIColor whiteColor];
            [_statusBtn setUserInteractionEnabled:YES];
        }
        if ([_status isEqualToString:@"2"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#ff0000"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:YES];
        }
        if ([_status isEqualToString:@"3"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#009b42"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:YES];
        }
        if ([_status isEqualToString:@"10"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#f703e5"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:YES];
        }
        if ([_status isEqualToString:@"5"])
        {
            _statusBtn.backgroundColor = [UIColor colorWithHexString:@"#00B8EC"];
            [_statusBtn setTitleColor:[UIColor whiteColor] forState:0];
            [_statusBtn setUserInteractionEnabled:YES];
        }
    }
    
}

-(void)statueBtnClick:(UIButton *)btn
{
    NSLog(@"点击的是 那个 %ld",(long)btn.tag);
}
@end
